home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trusted Irix /B 4.0.4
/
Trusted-Irix B-4.0.1.iso
/
dist
/
eoe1.idb
/
usr
/
include
/
sys
/
inode.h.z
/
inode.h
Wrap
C/C++ Source or Header
|
1992-04-03
|
7KB
|
206 lines
#ifndef __SYS_INODE_H__
#define __SYS_INODE_H__
/**************************************************************************
* *
* Copyright (C) 1990, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "$Revision: 3.27 $"
/*
* The I node is the focus of all file activity in unix.
* There is a unique inode allocated for each active file,
* each current directory, each mounted-on file, text file,
* and the root. An inode is 'named' by its dev/inumber
* pair. (iget/iget.c) Data, from mode on, is read in from
* permanent inode on volume.
*/
#include "sys/sema.h"
#ifdef TRUSTEDIRIX
#include "sys/mac_label.h"
#endif /* TRUSTEDIRIX */
typedef struct inode
{
struct inode *i_forw; /* inode hash chain */
struct inode *i_back; /* '' */
struct inode *av_forw; /* freelist chain */
struct inode *av_back; /* '' */
int *i_fsptr; /* "typeless" pointer to fs dependent */
long i_number; /* i number, 1-to-1 with dev address */
ushort i_ftype; /* file type = IFDIR, IFREG, etc. */
short i_fstyp; /* File system type */
off_t i_size; /* size of file */
ushort i_uid; /* owner */
ushort i_gid; /* group of owner */
ushort i_flag;
ushort i_what; /* interest mask for imon */
lock_t i_reflock; /* reference counting spinlock */
cnt_t i_count; /* reference count */
short i_nlink; /* directory entries */
dev_t i_rdev; /* Raw device number */
dev_t i_dev; /* device where inode resides */
struct dquot *i_dquot; /* quota structure controlling this file */
struct mount *i_mntdev; /* ptr to mount dev inode resides on */
union i_u {
struct mount *i_mton;/* pntr to mount table entry */
/* that this inode is "mounted on" */
struct stdata *i_sp; /* Associated stream. */
struct socket *i_soc; /* unix domain socket */
} i_un;
struct fstypsw *i_fstypp; /* pointer to file system */
/* switch structure */
sema_t *i_flcksem; /* semaphore for file locking */
long *i_filocks; /* pointer to filock (structure) list */
sema_t i_lock; /* semaphore for inode lock */
ulong i_gen; /* generation number (for nfs) */
struct mregion *i_mreg; /* mapregion pointer */
/* next two pointers MUST be adjacent */
struct pfdat *i_pnext; /* delwri page next pointer */
struct pfdat *i_pprev; /* delwri page prev pointer */
#ifdef TRUSTEDIRIX
mac_label *i_label; /* for Mandatory Access Control */
long i_plang; /* index into Plan G database */
#endif /* TRUSTEDIRIX */
} inode_t;
struct ifreelist
{
struct inode *i_forw; /* must match struct inode !*/
struct inode *i_back; /* '' */
struct inode *av_forw;
struct inode *av_back;
sema_t ih_lock; /* free list lock */
};
#define i_sptr i_un.i_sp
#define i_mnton i_un.i_mton
#define i_socket i_un.i_soc
#define ISMAPPED(ip) (ip)->i_mreg
#define ISDIRTY(ip) ((ip)->i_pnext != (struct pfdat *)(&(ip)->i_pnext))
#define IP_PGEND(ip) ((struct pfdat *)(&(ip)->i_pnext))
/* flags */
/*#define ILOCK 0x01 /* inode is locked */
#define IUPD 0x02 /* file has been modified */
#define IACC 0x04 /* inode access time to be updated */
#define IMOUNT 0x08 /* inode is mounted on */
#define IWANT 0x10 /* some process waiting on lock */
#define ITEXT 0x20 /* inode is pure text prototype */
#define ICHG 0x40 /* inode has been changed */
#define ISYN 0x80 /* do synchronous write for iupdate */
#define IADV 0x100 /* advertised */
#define IDOTDOT 0x200 /* object of remote mount */
#define INODELAY 0x400 /* do immediate write for iupdate */
#define IRMOUNT 0x800 /* remotely mounted */
#define IISROOT 0x1000 /* This is a root inode of an fs */
#define IWROTE 0x2000 /* write has happened since open */
#define IHASH 0x4000 /* inode is on a hash list */
#define IWASMMAP 0x8000 /* file is or was mmap'ed at some point */
/* allows us to keep caches consistent */
/*
* File types (inode formats).
*/
#define IFMT 0xf000 /* type of file */
#define IFDIR 0x4000 /* directory */
#define IFCHR 0x2000 /* character special */
#define IFBLK 0x6000 /* block special */
#define IFREG 0x8000 /* regular */
#define IFMPC 0x3000 /* multiplexed char special */
#define IFMPB 0x7000 /* multiplexed block special */
#define IFIFO 0x1000 /* fifo special */
#define IFLNK 0xA000 /* symbolic link */
#define IFSOCK 0xC000 /* socket */
/*
* File execution and access modes.
*/
#define ISUID 0x800 /* set user id on execution */
#define ISGID 0x400 /* set group id on execution */
#define ISVTX 0x200 /* save swapped text even after use */
#define IREAD 0x100 /* read permission */
#define IWRITE 0x080 /* write permission */
#define IEXEC 0x040 /* execute permission */
#define ICDEXEC 0x020 /* cd permission */
#define IOBJEXEC 0x010 /* execute as an object file */
/* i.e., 410, 411, 413 */
#define IMNDLCK 0x001 /* mandatory locking set */
#define MODEMSK 0xfff /* Nine permission bits - read/write/ */
/* execute for user/group/others and */
/* ISUID, ISGID, and ISVTX */
/* This is another way of saying: */
/* (ISUID|ISGID|ISVTX| */
/* (IREAD|IWRITE|IEXEC)| */
/* ((IREAD|IWRITE|IEXEC)>>3)| */
/* ((IREAD|IWRITE|IEXEC)>>6)) */
#define PERMMSK 0x1ff /* Nine permission bits: */
/* ((IREAD|IWRITE|IEXEC)| */
/* ((IREAD|IWRITE|IEXEC)>>3)| */
/* ((IREAD|IWRITE|IEXEC)>>6)) */
#ifdef _KERNEL
extern struct inode inode[]; /* The inode table itself */
extern struct ifreelist ifreelist;
extern sema_t iflcksema;
extern lock_t mreg_lock;
#define plock(IP) { \
psema(&(IP)->i_lock, PINOD); \
ASSERT(valusema(&(IP)->i_lock) <= 0); \
}
#define cplock(IP) cpsema(&(IP)->i_lock)
#define prele(IP) { \
ASSERT(valusema(&(IP)->i_lock) <= 0); \
vsema(&(IP)->i_lock); \
}
#define IHOLD(IP) { \
int ihold_s = splock((IP)->i_reflock); \
ASSERT((IP)->i_count > 0); \
(IP)->i_count++; \
spunlock((IP)->i_reflock, ihold_s); \
}
#define IDROP(IP) { \
int idrop_s = splock((IP)->i_reflock); \
ASSERT((IP)->i_count > 1); \
--(IP)->i_count; \
spunlock((IP)->i_reflock, idrop_s); \
}
#define IRELE(IP) { \
plock(IP); \
iput(IP); \
}
extern struct inode *getinode(struct mount *, int, ino_t, int);
extern struct inode *iget(struct mount *, ino_t);
extern void iput(struct inode *);
extern void iuncache(struct inode *);
extern void ifreebusy(struct inode *);
extern int iflush(struct mount *);
#endif /* _KERNEL */
#endif /* __SYS_INODE_H__ */